#include "recipe.h"

using std::string;


string Ingredient::get_name(){return name;}
string Ingredient::get_key(){return key;}
float Ingredient::get_amount(){return amount;}


Ingredient::Ingredient()
	:key("DUMB"), name("Dummy ingredient"), amount(0)
{}

Ingredient::Ingredient(string ikey, string iname, float ivolume)
	:key(ikey), name(iname), amount(ivolume)
{}




string Recipe::get_key(){return key;}
string Recipe::get_name(){return name;}
std::vector <Ingredient> Recipe::get_ingredients(){return ingredients;}


Recipe::Recipe()
	:key("DUMB"), name("Dummy drink")
{
    ingredients.push_back(Ingredient());
}

Recipe::Recipe(string rkey, string rname)
	:key(rkey), name(rname)
{
}

Recipe::Recipe(string rkey, string rname, std::vector <Ingredient> ringredients)
	:key(rkey), name(rname)
{
	for (auto it = ringredients.begin(); it!= ringredients.end(); ++it)
	{
		ingredients.push_back(*it);
	}
}


float Recipe::get_volume()
{
    float total = 0;
        
    for ( auto it=ingredients.begin(); it!=ingredients.end(); ++it)
    {
        total += it->get_amount();
    }

    return total;
}

void Recipe::add_ingredient(string ikey, string iname, float ivolume)
{
    add_ingredient(Ingredient(ikey,iname,ivolume));
}

void Recipe::add_ingredient(Ingredient ingredient)
{
    ingredients.push_back(ingredient);
}
